package com.hgw.Demo04_BuilderPattern.Exercises6_7_4;

/**
 * Data time:2021/12/13 10:12
 * StudentID:2019112118
 * Author:hgw
 * Description:
 */
public class Director {
    public Computer construct(Builder cb) {
        Computer computer;
        cb.buildCpu();
        cb.buildMemory();
        cb.buildHardDisk();
        //通过钩子方法来控制产品的构建
        if (cb.isHost()) {
            cb.buildHost();
        }
        if (cb.isMonitor()) {
            cb.buildMonitor();
        }
        computer = cb.createComputer();
        return computer;
    }
}
